package mock


func Delete(ctx *CmdContext, s *Store) []byte {
	var count int
	var existKeys [][]byte
	for _, k := range ctx.Args {
		v, err := s.Get(k)
		if err != nil {
			return EncodeError(err.Error())
		}
		if v != nil {
			count++
			existKeys = append(existKeys, k)
		}
	}

	for _, k := range existKeys {
		if err := s.Del(k); err != nil {
			return EncodeError(err.Error())
		}
	}

	return EncodeInteger(int64(count))
}
